//
//  XCTuiJianCollectionViewCell.m
//  SoundOfNature
//
//  Created by 梁新昌 on 16/3/13.
//  Copyright © 2016年 梁新昌. All rights reserved.
//

#import "XCTuiJianCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation XCTuiJianCollectionViewCell
- (void)dealloc {
    [_picUrlImageView release];
    [_playButton release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.picUrlImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.picUrlImageView.userInteractionEnabled = YES;
        self.playButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.playButton setImage:[[UIImage imageNamed:@"Image-player"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        
        [self.contentView addSubview:self.picUrlImageView];
        [self.contentView addSubview:self.playButton];
    }
    return self;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.picUrlImageView.frame = self.bounds;
    
    self.playButton.frame = CGRectMake(self.bounds.size.width / 2 - 15, self.bounds.size.height / 2 - 15, 30, 30);
    
}
- (void)setTuiJianModel:(XCTuiJianModel *)tuiJianModel {
    if (_tuiJianModel != tuiJianModel) {
        [_tuiJianModel release];
        _tuiJianModel = [tuiJianModel retain];
    }
    [self.picUrlImageView sd_setImageWithURL:[NSURL URLWithString:tuiJianModel.picUrl] placeholderImage:[UIImage imageNamed:@"Image-p"]];
}
@end
